package com.contexticon.mediaTest;




/*
 * This file is part of VLCJ.
 *
 * VLCJ is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VLCJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VLCJ.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2009, 2010, 2011, 2012 Caprica Software Limited.
 */


import java.io.File;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.test.VlcjTest;

/**
 * Test demonstrating the {@link EmbeddedMediaPlayerComponent}.
 * <p>
 * Leaving aside the standard Swing initialisation code, there are only 
 * <em>two</em> lines of vlcj code required to create a media player and play
 * a video.
 */
public class MyEmbeddedPlayer extends VlcjTest {

  /**
   * Media player component.
   */
  private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
  
  
  /**
   * Application entry point.
   * 
   * @param args
   */
  public static void main(String[] args) {

	  System.out.println("Working Directory = " +
	           System.getProperty("user.dir"));
	  
	  
	  File file = new File("VLC.app/Contents/MacOS/lib/");  
				if (file.exists()) {
			System.setProperty("jna.library.path", "VLC.app/Contents/MacOS/lib/");
				}
				else {	
					System.setProperty("jna.library.path", "Win64\\");	
				}


	//			mediaPlayerComponent = 
    
    //MovieChooser chooser = new MovieChooser();
    //chooser.setMediaPlayer(mediaPlayerComponent.getMediaPlayer());
    //chooser.setVisible(true);
    
    setLookAndFeel();
    
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        new MyEmbeddedPlayer().start("/Users/dglodzik/Movies/FrontRoll.flv");
      }
    });
  }
  
  /**
   * Create a new test. 
   */
  private MyEmbeddedPlayer() {
    JFrame frame = new JFrame("vlcj Media Player Component Test");
    
    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    frame.setContentPane(mediaPlayerComponent);
    
    frame.setLocation(100, 100);
    frame.setSize(150, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }

  /**
   * Start playing a movie.
   * 
   * @param mrl mrl
   */
  private void start(String mrl) {
    // One line of vlcj code to play the media...
	  mediaPlayerComponent.setSize(150, 300);	
    mediaPlayerComponent.getMediaPlayer().playMedia(mrl);
	  mediaPlayerComponent.setSize(150, 300);	
  }
}